home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Programming in C++ - Start to Finish
/
GameProgrammingS.iso
/
Peon
/
PeonSDK-Win32-1.0.0.exe
/
{app}
/
PeonMain
/
source
/
IApplication.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2005-11-20
|
1KB
|
64 lines
#include "FileLogger.h"
#include "IApplication.h"
namespace peon
{
IApplication::IApplication()
{
m_pCurrentState = NULL;
}
IApplication::~IApplication()
{
}
bool IApplication::loadState(int key, IApplicationState* pState)
{
if(!pState->onLoad())
{
return false;
}
m_oStates.insert(std::make_pair(key, pState));
return true;
}
void IApplication::setCurrentState( int key )
{
std::map<int, IApplicationState*>::iterator it;
it = m_oStates.find(key);
if (it == m_oStates.end())
{
FileLogger::getSingleton().logError("IApplication", "Couldn't find state");
return;
}
else
{
m_pCurrentState = it->second;
}
}
void IApplication::unloadStates()
{
IApplicationState* pState;
for(std::map<int, IApplicationState*>::iterator it = m_oStates.begin();
it != m_oStates.end();
it++)
{
pState = (IApplicationState*)it->second;
pState->onUnload();
PEON_DELETE( pState );
}
//clear the map
m_oStates.clear();
}
}